package org.ace.dao.impl;

import java.util.List;

import org.ace.dao.IPlayerDAO;
import org.ace.dao.model.Player;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class PlayerDAOImpl extends SqlMapClientDaoSupport implements IPlayerDAO {

    public PlayerDAOImpl() {
        super();
    }

    public void save(Player player) {
        getSqlMapClientTemplate().insert("player.insert", player);
    }

    public int update(Player player) {
        int rows = getSqlMapClientTemplate().update("player.update", player);
        return rows;
    }

    public Player get(String username) {
        Player key = new Player();
        key.setUsername(username);
        Player record = (Player) getSqlMapClientTemplate().queryForObject("player.select", key);
        return record;
    }

    public int remove(Integer userid) {
        Player key = new Player();
        key.setUserid(userid);
        int rows = getSqlMapClientTemplate().delete("player.delete", key);
        return rows;
    }
	@SuppressWarnings("unchecked")
	@Override
	public List<Player> getByAccountId(Integer accId) {
		return (List<Player>) getSqlMapClientTemplate().queryForList("player.selectByAccountId",accId);
	}
}